
PROGRAM _INIT
//	gRobotCtrl.EtherNetIP.Status.ModeAct := 2;
//	gRobotCtrl.EtherNetIP.Command.Override := 100;
	 
END_PROGRAM

PROGRAM _CYCLIC
	
	gHmi.Status.EStop := gDiEstop;
	IF EDGEPOS(gHmi.Control.PowerOn) THEN
		gCmdPower := 1;
	END_IF
	IF EDGEPOS(gHmi.Control.StartDemo) THEN
		gCmdShuttleStart := 1;
		gHmi.Control.StopDemo := 0;
	END_IF
	IF EDGEPOS(gHmi.Control.StopDemo) THEN
		gCmdStopping := 1;
		gCmdShuttleStart := 0;
		gHmi.Control.StartDemo := 0;
	END_IF
	
	gHmi.Status.PowerOn := gDemoMaster.Status.PowerOn;
	(* StartDemo *)
	
	CASE commissioningStep OF
		
		START_DEMO_WELCOME:
			
			gHmi.Commissioning.Stat.CurrentStep			:= '';
			gHmi.Commissioning.Stat.CurrentContent		:= 'contentStartWelcome';
			gHmi.Commissioning.Stat.EnableNextBtn		:= FALSE;
			gHmi.Commissioning.Stat.EnableConfirmBtn	:= FALSE;
			gHmi.Commissioning.Stat.ShowNextBtn			:= FALSE;
			gHmi.Commissioning.Stat.ShowConfirmBtn		:= FALSE;
			gHmi.Commissioning.Stat.ShowSkipBtn			:= FALSE;
			gHmi.Commissioning.Stat.ShowBackBtn			:= FALSE;
			gHmi.Commissioning.Stat.ShowCancelBtn		:= FALSE;
			gHmi.Commissioning.Stat.ShowStartBtn		:= TRUE;
			
			IF gHmi.Commissioning.Ctrl.Start THEN
				gHmi.Commissioning.Ctrl.Start			:= FALSE;
				commissioningStep						:= START_DEMO_POWER_ON;				
			END_IF;
			
			
		START_DEMO_POWER_ON:
			
			gSafeLogic.Cmd.PowerOn						:= TRUE;
			
			gHmi.Commissioning.Stat.EnableNextBtn		:= FALSE;
			gHmi.Commissioning.Stat.ShowNextBtn			:= FALSE;
			gHmi.Commissioning.Stat.ShowConfirmBtn		:= TRUE;
			gHmi.Commissioning.Stat.ShowSkipBtn			:= FALSE;
			gHmi.Commissioning.Stat.ShowBackBtn			:= TRUE;
			gHmi.Commissioning.Stat.ShowCancelBtn		:= TRUE;
			gHmi.Commissioning.Stat.ShowStartBtn		:= FALSE;
			;
			gHmi.Commissioning.Stat.CurrentStep			:= 'Step 1 of 1';
			gHmi.Commissioning.Stat.CurrentContent		:= 'contentStartpowerOn';
			
			gHmi.Commissioning.Stat.TrakNotReadyForPower	:=	NOT(gAssembly.ReadyForPowerOn);
			gHmi.Commissioning.Stat.CommunicationNotReady	:=	NOT(gAssembly.CommunicationReady);
			gHmi.Status.NotEStop							:=	NOT(gHmi.Status.EStop);
			
			IF gHmi.Status.EStop = TRUE THEN
				gHmi.Commissioning.Stat.EStopText		:=	'$$IAT/DemoStart/ID_Check1EStopP';
			ELSE
				gHmi.Commissioning.Stat.EStopText		:=	'$$IAT/DemoStart/ID_Check1EStopR';
			END_IF
			
			IF gHmi.Status.Error = TRUE THEN
				gHmi.Commissioning.Stat.ErrorStyleText	:=	'LabelRed';
				gHmi.Commissioning.Stat.ErrorStyleImg	:=	'imgRed';
			ELSE
				gHmi.Commissioning.Stat.ErrorStyleText	:=	'LabelBlue';
				gHmi.Commissioning.Stat.ErrorStyleImg	:=	'imgBlue';
			END_IF
			
			IF	gHmi.Status.EStop = FALSE AND gAssembly.ReadyForPowerOn = TRUE AND gAssembly.CommunicationReady = TRUE THEN
				gHmi.Commissioning.Stat.EnablePowerOnBtn := TRUE;
			ELSE
				gHmi.Commissioning.Stat.EnablePowerOnBtn := FALSE;
			END_IF
			
			IF gHmi.Status.PowerOn = TRUE THEN
				gHmi.Commissioning.Stat.EnableConfirmBtn := TRUE;
			ELSE
				gHmi.Commissioning.Stat.EnableConfirmBtn := FALSE;
			END_IF
			
			checkUserInput;
		
		
	END_CASE;
	

	(* Kpi *)
	
	//gAssembly.ShuttlesPresent	:=	148;
	gHmi.Status.MachineOverride	:=	100.0;	
	gHmi.Status.ShuttleVelocity	:=	1;
	gHmi.Status.BalancerTemp := gAcpTrakMaxTemp;
	gHmi.Status.AcpTrakInfoPower	:=	'imgGreen';
	gHmi.Status.AcpTrakInfoPowerOn	:=	'imgYellow';
	gHmi.Status.AcpTrakInfoAlarm	:=	'imgRed';
	gHmi.Status.AcpTrakInfoSpeed	:=	'imgBlue';
	
	gHmi.Status.RobotInfoPower		:=	'imgGreen';
	gHmi.Status.RobotInfoPowerOn	:=	'imgGreen';
	gHmi.Status.RobotInfoAlarm		:=	'imgGreen';
	gHmi.Status.RobotInfoSpeed		:=	'imgBlue';
	
	IF gHmi.Control.StartDemo	=	TRUE THEN
		gHmi.Commissioning.Stat.CollabBtnImgStart	:=	'Media/Collaboration/StartOn.png';
	ELSE
		gHmi.Commissioning.Stat.CollabBtnImgStart	:=	'Media/Collaboration/StartOff.png';
	END_IF
	
	IF gHmi.Control.Dance	=	TRUE THEN
		gHmi.Commissioning.Stat.CollabBtnImgDance	:=	'Media/Collaboration/DanceOn.png';
	ELSE
		gHmi.Commissioning.Stat.CollabBtnImgDance	:=	'Media/Collaboration/DanceOff.png';
	END_IF
	
	IF gHmi.Control.Trace	=	TRUE THEN
		gHmi.Commissioning.Stat.CollabBtnImgTrace	:=	'Media/Collaboration/TraceOn.png';
	ELSE
		gHmi.Commissioning.Stat.CollabBtnImgTrace	:=	'Media/Collaboration/TraceOff.png';
	END_IF
	
	IF gHmi.Control.Filling	=	TRUE THEN
		gHmi.Commissioning.Stat.CollabBtnImgFilling	:=	'Media/Collaboration/FillingOn.png';
	ELSE
		gHmi.Commissioning.Stat.CollabBtnImgFilling	:=	'Media/Collaboration/FillingOff.png';
	END_IF
	
	IF gHmi.Control.Auto	=	TRUE THEN
		gHmi.Commissioning.Stat.CollabBtnImgAuto	:=	'Media/Collaboration/AutoOn.png';
	ELSE
		gHmi.Commissioning.Stat.CollabBtnImgAuto	:=	'Media/Collaboration/AutoOff.png';
	END_IF
	
	IF gHmi.Control.StopDemo	=	TRUE THEN
		gHmi.Commissioning.Stat.CollabBtnImgStop	:=	'Media/Collaboration/StopOn.png';
	ELSE
		gHmi.Commissioning.Stat.CollabBtnImgStop	:=	'Media/Collaboration/StopOff.png';
	END_IF
		
	 
END_PROGRAM

PROGRAM _EXIT
	(* Insert code here *)
	 
END_PROGRAM

